/*
* Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const { CustomBase } = require("./CustomBase");
const { X2DBeta } = require("../../../engine/graphics/X2DInterface");
const { Scr } = require("../../../engine/XDefine");
const { XTools } = require("../../../engine/XTools");

class CustomNode extends CustomBase {
    constructor(name) {
        super("node", name);
        this.running = false;
        this.code = "";
    }
    onDrawExtend(dx, dy) {
        let y = dy;
        this.running = false;
        const { RuntimeManager } = require("../0/RuntimeManager");
        for (let name of Object.keys(RuntimeManager.getInstance().nodes)) {
            if (name == "/" + this.name) {
                this.running = true;
            }
        };
        if (this.running) {
            X2DBeta.drawText("运行中", 12, dx + 4, y + 8, 1, 1, 0, -1, -2, 0xff00ff00);
        } else {
            X2DBeta.drawText("已停止", 12, dx + 4, y + 8, 1, 1, 0, -1, -2, 0xffff0000);
        }
        y += 16;
        return y - dy;
    }
    onDraw(offx = 0, offy = 0, locked = false) {
        super.onDraw(offx, offy, locked);
    }
    onTouch(msg, x, y) {
        if (super.onTouch(msg, x, y)) {
            return true;
        }
        return false;
    }
}

module.exports = {
    CustomNode,
}